<!--
 * @FileDescription 毫米波碰撞检测配置
 * @Author 杨宇翔
 * @Date 20220531 15:04:55
 * @LastEditors 杨宇翔
 * @LastEditTime 20220531 15:04:55
-->
<template>
    <div class="detection-configuration">
        <div class="container">
            <div class="header">
                <span>碰撞检测配置</span>
                <span class="material-icons"
                    @click="UsageForMillimeterWaveRadarComponent.Default.NavigateToPreviousAsync()">×</span>
            </div>
            <div class="content">
                <input type="checkbox" name="碰撞检测配置" id="报警信息重置" hidden v-model="configuration.ResetWarning">
                <label for="报警信息重置">
                    <span></span>
                    <span>报警信息重置</span>
                </label>

                <input type="checkbox" name="碰撞检测配置" id="是否使能配置" hidden v-model="configuration.Activation">
                <label for="是否使能配置">
                    <span></span>
                    <span>是否使能配置</span>
                </label>

                <i></i>

                <input type="checkbox" name="碰撞检测配置" id="清除所有区域" hidden v-model="configuration.ClearRegions">
                <label for="清除所有区域">
                    <span></span>
                    <span>清除所有区域</span>
                </label>

                <input type="checkbox" name="碰撞检测配置" id="最短时间是否生效" hidden v-model="configuration.MinTimeValid">
                <label for="最短时间是否生效">
                    <span></span>
                    <span>最短时间是否生效</span>
                </label>

                <div class="time-setting">
                    <span class="fs16 colorwhite">最短时间(s)</span>
                    <input type="number" name="碰撞检测配置" id="最短时间" :min="0" :max="25.5" :step="0.1"
                        v-model="configuration.MinTime">
                </div>
            </div>
            <button class="reset colorwhite" type="button"
                @click="CollisionComponent.Default.SetCollisionAsync(configuration.ResetWarning, configuration.Activation, configuration.ClearRegions, configuration.MinTimeValid, configuration.MinTime)">
                <span>保存配置</span>
            </button>
        </div>
    </div>
</template>

<script setup lang="ts">
import { ClientMessage } from '@runtime/generate/message/ClientMessage';
import { reactive, UnwrapNestedRefs } from 'vue';
import { CollisionComponent, UsageForMillimeterWaveRadarComponent } from './ExamComponent';

const configuration: UnwrapNestedRefs<ClientMessage.MillimeterWaveRadarCollisionConfiguration> = reactive(new ClientMessage.MillimeterWaveRadarCollisionConfiguration(false, false, false, false, 10));
</script>

<style scoped>
.detection-configuration {
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;

    backdrop-filter: blur(1rem);
}

.container {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);

    width: 108rem;
    height: 30rem;

    display: flex;
    flex-direction: column;
    align-items: stretch;

    border-radius: 2rem;
    border: solid 0.6rem transparent;
    background-image: linear-gradient(#131620, #131620),
        linear-gradient(90deg, #218cde, #807de1);
    background-origin: border-box;
    background-clip: content-box, border-box;
}

.header {
    width: 100%;

    padding: 2rem;

    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header>span:first-of-type {
    color: white;
    font-size: 2.4rem;
    font-weight: 500;
}

.header>.material-icons {
    color: #81859C;
    font-size: 3.6rem;
}

.content {
    padding-left: 4rem;
    padding-right: 4rem;

    display: grid;
    grid-template-columns: 17fr 17fr 36fr;
    grid-template-rows: 2fr 3fr;
    gap: 1rem 8rem;
}

label {
    display: inline-flex;
    justify-content: flex-start;
    align-items: center;
    gap: 1rem;
}

label>span:first-of-type {
    display: inline-block;
    width: 1.6rem;
    height: 1.6rem;

    background-image: url('/static/Exam/ic_checkbox_normal.png');
}

.content>input:checked+label>span:first-of-type {
    background-image: url('/static/Exam/ic_checkbox_select.png');
}

label>span:last-of-type {
    color: #81859C;
    font-size: 1.6rem;
}

.material-icons {
    color: #81859C;
}

.time-setting {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 1.5rem;
}

.time-setting>span {
    line-height: 3.6rem;
    color: #81859C;
    font-size: 1.6rem;
}

.time-setting>input {
    flex-grow: 1;
    height: 100%;

    border: none;
    outline: none;

    padding-left: 1.5rem;

    color: #81859C;
    font-size: 1.6rem;

    border-radius: 0.6rem;
    border: 0.1rem solid #36384B;

    background-color: transparent;
}

.time-setting>input:focus {
    border: solid 0.1rem;
    border-image: linear-gradient(90deg, rgba(128, 125, 225, 1), rgba(33, 140, 222, 1)) 1 1;
}


.time-setting>input::-webkit-inner-spin-button,
.time-setting>input::-webkit-outer-spin-button {
    display: none;
}

button {
    width: 25rem;
    height: 10rem;

    margin: auto;

    background-image: url('/static/Exam/btn-bg.png');
    background-repeat: no-repeat;
    background-position-y: -0.5rem;
    background-size: cover; 
}

button>span {
    color: white;
    font-size: 3rem;
}
</style>